/**
 * Created by mapbar_front on 2019/7/5.
 */
//现在想把BrotherA的值，传给BrotherB。
//最简单的方法就是 从BrotherA传给父组件，然后通过父组件传给子组件。

import React,{ Component } from 'react';
import { Button } from 'antd';
import target from './Utils';

class BrotherA extends Component{
    constructor(props){
        super(props);
        this.state = {
            str: '兄弟A',
        }
    }
    componentDidMount(){
        console.log('BrotherA',new Date().getTime());
    }
    clickHandle(){

        this.props.information && this.props.information(this.state.str);
    }
    handle(){
        console.log('handle',new Date().getTime());
        target.fire({type:'message',message:'Hello,World!'});
    }
    render(){
        return(
            <div>
                <Button type='primary' style={{marginRight:10}} onClick={()=>{ this.clickHandle()}}>
                    BrotherA
                </Button>
                <Button type='primary' onClick={ ()=> this.handle()}>
                    传值给B
                </Button>
            </div>
        )
    }
}
export default BrotherA;

